~ chicken-core (chicken-5) /manual/Module (chicken pathname)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken pathname)56This module provides procedures for manipulating paths. If you want7to operate on the files and directories which the paths represent, see8[[Module (chicken file)]].910=== absolute-pathname?1112<procedure>(absolute-pathname? PATHNAME)</procedure>1314Returns {{#t}} if the string {{PATHNAME}} names an absolute15pathname, and returns {{#f}} otherwise.1617=== decompose-pathname1819<procedure>(decompose-pathname PATHNAME)</procedure>2021Returns three values: the directory-, filename- and extension-components22of the file named by the string {{PATHNAME}}.23For any component that is not contained in {{PATHNAME}}, {{#f}} is returned.2425=== make-pathname26=== make-absolute-pathname2728<procedure>(make-pathname DIRECTORY FILENAME [EXTENSION])</procedure><br>29<procedure>(make-absolute-pathname DIRECTORY FILENAME [EXTENSION])</procedure>3031Returns a string that names the file with the32components {{DIRECTORY, FILENAME}} and (optionally)33{{EXTENSION}} with {{SEPARATOR}} being the directory separation indicator34(usually {{/}} on UNIX systems and {{\}} on Windows, defaulting to whatever35platform this is running on).36{{DIRECTORY}} can be {{#f}} (meaning no37directory component), a string or a list of strings. {{FILENAME}}38and {{EXTENSION}} should be strings or {{#f}}.39{{make-absolute-pathname}} returns always an absolute pathname.4041=== pathname-directory42=== pathname-file43=== pathname-extension4445<procedure>(pathname-directory PATHNAME)</procedure><br>46<procedure>(pathname-file PATHNAME)</procedure><br>47<procedure>(pathname-extension PATHNAME)</procedure>4849Accessors for the components of {{PATHNAME}}. If the pathname does50not contain the accessed component, then {{#f}} is returned.5152=== pathname-replace-directory53=== pathname-replace-file54=== pathname-replace-extension5556<procedure>(pathname-replace-directory PATHNAME DIRECTORY)</procedure><br>57<procedure>(pathname-replace-file PATHNAME FILENAME)</procedure><br>58<procedure>(pathname-replace-extension PATHNAME EXTENSION)</procedure>5960Return a new pathname with the specified component of {{PATHNAME}}61replaced by a new value.6263=== pathname-strip-directory64=== pathname-strip-extension6566<procedure>(pathname-strip-directory PATHNAME)</procedure><br>67<procedure>(pathname-strip-extension PATHNAME)</procedure>6869Return a new pathname with the specified component of {{PATHNAME}}70stripped.7172=== normalize-pathname7374<procedure>(normalize-pathname PATHNAME [PLATFORM])</procedure>7576Performs a simple "normalization" on the {{PATHNAME}}, suitably for77{{PLATFORM}}, which should be one of the symbols {{windows}}78or {{unix}} and defaults to on whatever platform is currently79in use. All relative path elements and duplicate separators are processed80and removed. If {{NAME}} ends with81a {{/}} or is empty, the appropriate slash is appended to the tail.8283No directories or files are actually tested for existence; this84procedure only canonicalises path syntax.8586=== directory-null?8788<procedure>(directory-null? DIRECTORY)</procedure>8990Does the {{DIRECTORY}} consist only of path separators and the period?9192{{DIRECTORY}} may be a string or a list of strings.9394=== decompose-directory9596<procedure>(decompose-directory DIRECTORY)</procedure>9798Returns 3 values: the {{base-origin}}, {{base-directory}}, and the99{{directory-elements}} for the {{DIRECTORY}}.100101; {{base-origin}} : a {{string}} or {{#f}}. The drive, if any.102; {{base-directory}} : a {{string}} or {{#f}}. A directory-separator when {{DIRECTORY}} is an {{absolute-pathname}}.103; {{directory-elements}} : a {{list-of string}} or {{#f}}. The non-directory-separator bits.104105{{DIRECTORY}} is a {{string}}.106107* On Windows {{(decompose-directory "c:foo/bar")}} => {{"c:" #f ("foo" "bar")}}108109=== Windows specific notes110111Use of UTF8 encoded strings for pathnames is not supported. Windows112uses a 16-bit UNICODE encoding with special system calls for113wide-character support. Only single-byte string encoding can be used.114115---116Previous: [[Module (chicken module)]]117118Next: [[Module (chicken platform)]]